package net.lanelife.casino.caipiao.dto.admin;

import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;

import net.lanelife.casino.caipiao.entity.PaymentMerchant;
import net.lanelife.casino.caipiao.entity.PaymentMerchant_;
import net.lanelife.casino.common.dto.support.GenericTable;
import net.lanelife.casino.common.entity.json.serialize.CurrencySerializer;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.collect.Lists;

/**
 * @author Lane
 * 
 * 支付商户表格
 *
 * @param <DTO>
 */
public class PaymentMerchantTable<DTO> extends GenericTable<DTO, PaymentMerchant> {

	private static final long serialVersionUID = 8864366479769098332L;

	@JsonSerialize(using = CurrencySerializer.class)
	private Double currentBalance;
	
	public PaymentMerchantTable() {}
	
	public PaymentMerchantTable(Double currentBalance) {
		super();
		this.currentBalance = currentBalance;
	}

	@Override
	public List<Selection<?>> buildExpression(Root<PaymentMerchant> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
		List<Selection<?>> columns = Lists.newArrayList();
		columns.add(builder.sum(root.get(PaymentMerchant_.currentBalance)));
		return columns;
	}

}
